#ifndef SIMULATIONRUNNERMPI_HPP
#define SIMULATIONRUNNERMPI_HPP

#include "solverBase.hpp"
#include "simulationTime.hpp"
#include "structMeshPart.hpp"

namespace hms
{

template<typename MeshType, typename SolverType>
void advance(
	const StructMeshPart<MeshType>& part,
	Time& time,
	SolverType& solver
){
	scalar timeStep { solver.calculateTimeStep() };
	MPI_Allreduce(
		MPI_IN_PLACE, &timeStep, 1, MPI_SCALAR, MPI_MIN, part.comm()
	);
	time.step(timeStep);
	solver.advance(time);
	for ( Field<MeshType>& field : solver.fields() )
		part.getNeighbourValues( field );
}

} // end namespace hms


#endif